package com.ruoyi.crm.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.crm.domain.Clue;
import com.ruoyi.crm.domain.vo.ClueVo;
import com.ruoyi.crm.domain.vo.FalseClueVo;
import com.ruoyi.crm.service.IClueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/crm/clue/track")
public class ClueTrackController  extends BaseController {
    @Autowired
    private IClueService clueService;

    /**
     * 查询线索管理列表
     */
    @Log(title = "线索跟进记录", businessType = BusinessType.EXPORT)
    @PostMapping
    public AjaxResult list(@RequestBody ClueVo clueVo)
    {
        clueVo.setStatus(Clue.Status.JXZ.getValue());
        return toAjax(clueService.updateClue(clueVo));
    }

    /**
     * 转伪线索
     */
    @Log(title = "线索跟进记录", businessType = BusinessType.EXPORT)
    @PutMapping("/fake/{id}")
    public AjaxResult fake(@RequestBody FalseClueVo falseClueVo)
    {
        return toAjax(clueService.fake(falseClueVo));
    }

    /**
     * 捞取
     */
    @Log(title = "线索跟进记录", businessType = BusinessType.EXPORT)
    @PutMapping("/restore/{id}")
    public AjaxResult restore(@RequestBody FalseClueVo falseClueVo)
    {
        return toAjax(clueService.restore(falseClueVo));
    }

    /**
     * 转商机
     */
    @Log(title = "线索跟进记录", businessType = BusinessType.EXPORT)
    @PutMapping("/transform/{clueId}")
    public AjaxResult transform(@RequestBody FalseClueVo falseClueVo)
    {
        return toAjax(clueService.transform(falseClueVo));
    }

}
